{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# White-box Attack on CIFAR10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "\n",
    "sys.path.insert(0, '..')\n",
    "import torchattacks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load model and data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Files already downloaded and verified\n",
      "[Data loaded]\n",
      "[Model loaded]\n",
      "Acc: 100.00 %\n"
     ]
    }
   ],
   "source": [
    "sys.path.insert(0, '..')\n",
    "import robustbench\n",
    "from robustbench.data import load_cifar10\n",
    "from robustbench.utils import load_model, clean_accuracy\n",
    "\n",
    "images, labels = load_cifar10(n_examples=5)\n",
    "print('[Data loaded]')\n",
    "\n",
    "device = \"cuda\"\n",
    "model = load_model('Standard', norm='Linf').to(device)\n",
    "acc = clean_accuracy(model, images.to(device), labels.to(device))\n",
    "print('[Model loaded]')\n",
    "print('Acc: %2.2f %%'%(acc*100))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Adversarial Attack"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from torchattacks import PGD\n",
    "from utils import imshow, get_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PGD(model_name=WideResNet, device=cuda:0, return_type=float, attack_mode=default, targeted=False, normalization_used=False, eps=0.03137254901960784, alpha=0.008888888888888889, steps=10, random_start=True)\n"
     ]
    }
   ],
   "source": [
    "atk = PGD(model, eps=8/255, alpha=2/225, steps=10, random_start=True)\n",
    "print(atk)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# When normalization used:\n",
    "# atk.set_normalization_used(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "adv_images = atk(images, labels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAATkAAAFGCAYAAAARlejlAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAlk0lEQVR4nO3da5CcZ3Un8P/p+1x6bpqLLiPrZvkqQHYpxllz8YYADoFgUguFd4syFS/mQ6gyW6kKxB8WJ1VJ2BSXTW1twRrsYKq4uRYILEsSjDFrnEKAbIwkW5YlS7I0mtHcbz19m+4++6Fbu2MhnfNqpjUzeur/q1KNpp8zz/v02++cebv79HlFVUFEFKrYWi+AiOhKYpIjoqAxyRFR0JjkiChoTHJEFDQmOSIKGpMcEQWNSY4gIrkl/2oiUljy/X+4gtu9SUQOiMh049+PReSmy/h5FZGFxjrPisjnRCTexPU9ICInG9s4IiLXNWtuWj1McgRVbT//D8BpAO9ZctvXzseJSKLJmx4G8O8A9ADoBfB9AN+8zDne0Fj32wD8ewAfuTBgOesWkf8I4D4AfwigHcC7AUxc7jy09pjk6JJE5E4RGRKRT4jIOQD/ICIfFpFnLohTEbm28f+0iHxGRE6LyKiIfFFEWi42v6rOqOoprX/sRgBUAVy7nLWq6ksAfgZgj4hsb6zpPhE5DeAnjbX9SeOMbFpE/kVEtl3ifscAfArAf1LVF7XuFVWdWs7aaG0xyZFnI+pnWtsA3B8h/r8AuA7AXtQT1hYA//n8oIjMiMiblv6AiMwAKAL4bwD+Zj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d1w/uwTvZv48XxRwAcUdXPLRlal/v3Uutdj/t3ta7pvGbFwI23sP8rgDiAR1X1r9dkIRGIyE7Uz96A+mUcv76e1isi3wBwJ+rdG0YBfArAPwJ4HMA1aFwXV1XXxYv9l1jvnag/lVIApwB89PzrMmtJRN4E4GcADgH/7/qSD6L+Ote627/Geu/BOtu/IvJ61N9YWHpN578SkQ1o4r7lJx6IKGj8xAMRBY1JjoiCxiRHREFjkiOioDHJEVHQmOSIKGhMckQUNCY5Igra/wVbDuXidV+FhwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 360x1080 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "idx = 0\n",
    "pre = get_pred(model, adv_images[idx:idx+1], device)\n",
    "imshow(adv_images[idx:idx+1], title=\"True:%d, Pre:%d\"%(labels[idx], pre))"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "1ceb8aea646a0c712ed5db194d127de24ece80f87032283552cbe7de982c3798"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
